package com.wanjia.bpsapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanjia.bpsapi.mapper.WjSupplierMapper;
import com.wanjia.bpsapi.mapper.WjUserMapper;
import com.wanjia.bpsapi.pojo.dto.WjUserName;
import com.wanjia.bpsapi.pojo.entity.WjStoreProduct;
import com.wanjia.bpsapi.pojo.entity.WjUser;
import com.wanjia.bpsapi.service.IWjUserService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author wyn
 * @since 2023-02-13
 */
@Service
public class WjUserServiceImpl extends ServiceImpl<WjUserMapper, WjUser> implements IWjUserService {

    @Setter(onMethod_ = @Autowired)
    private WjUserMapper mapper;

    @Autowired
    WjSupplierMapper wjSupplierMapper;

    @Override
    public List<WjUserName> getUsernames() {
        return mapper.getUsernames();
    }

    @Override
    public String getUser(int uid) {
        WjUser wjUser = mapper.selectById(uid);
        String location = wjUser.getLocation();
        return location;
    }

    @Override
    public int addUser(WjUser wjUser) {
        /*Integer id = wjUser.getUid();
        WjUser data = mapper.selectById(id);
        if (data !=null){
            mapper.deleteById(data.getUid());
        }*/
        //mapper.delete(new QueryWrapper<>());
        int i = mapper.insert(wjUser);
        return i;
    }


}
